/**
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

#import "AppDelegate.h"
#import <React/RCTBundleURLProvider.h>
#import <React/RCTBridge.h>

#import <Bugly/Bugly.h>
#import <GizWifiSDK/GizWifiSDK.h>
#import "LoginViewController.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    //错误日志上报
    [Bugly startWithAppId:@"d01e9040cb"];
    
    [self customizeInterface];
    [self initGiz];
    
    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    self.window.backgroundColor = [UIColor whiteColor];
    
    LoginViewController *vc = [[LoginViewController alloc] init];
    _nav = [[UINavigationController alloc] initWithRootViewController:vc];
    self.window.rootViewController = _nav;
    
    [self.window makeKeyAndVisible];
    
    return YES;
}

- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
    return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#else
    return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}

- (void) initGiz{
    NSDictionary *parameters =@{@"appId":GizAppId,@"appSecret": GizAppSecret};
    [GizWifiSDK startWithAppInfo:parameters productInfo:nil cloudServiceInfo: nil autoSetDeviceDomain:YES];
}

- (void)customizeInterface {
    _navigationBarAppearance = [UINavigationBar appearance];
    //navigationBarAppearance.barTintColor = [UIColor clearColor];
    _navigationBarAppearance.translucent = YES;

    //设置导航栏背景图片为一个空的image，这样就透明了
    [_navigationBarAppearance setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];
    //去掉透明后导航栏下边的黑边
    [_navigationBarAppearance setShadowImage:[[UIImage alloc] init]];
    
}

@end
